package com.codeZ.CompositePattern.actualCombat;

/**
 * 文件节点
 *
 * @author codeZhang
 * @Date 2024/8/15 11:06
 */
public class Leaf extends Component {

    public Leaf(String name, long size) {
        super.name = name;
        super.size = size;
    }

    @Override
    public void add(Component component) {
        throw new UnsupportedOperationException("叶子节点不支持添加子节点");
    }

    @Override
    public void remove(Component component) {
        throw new UnsupportedOperationException("叶子节点不支持删除子节点");
    }

    @Override
    public void display(int depth) {
        for (int i = 0; i < depth; i++) {
            System.out.print("-");
        }
        System.out.println(getName());

    }

    @Override
    public String getName() {
        return super.name;
    }

    @Override
    public long getSize() {
        return super.size;
    }
}
